﻿using System.Collections.Generic;
using JetBrains.Annotations;



namespace Crocodile.CsharpLanguage.Tree
{
    public class CsListStatement : CsStatement
    {

        [NotNull]
        public readonly IList<string> Items =
            new List<string>();

        public string Head = "";
        public string Tail = "";
        public string Delimiter = "";
        public string EmptyStub = "";


        public override string[] Text
        {
            get
            {
                int n = Items.Count;
                switch (n)
                {
                    case 0:
                        return new[] {EmptyStub};

                    case 1:
                        return new[] {Head + Items[0] + Tail};

                    default:
                        string[] text = new string[n+1];
                        text[0] = Head;
                        for (int i = 1; i <= n; i++)
                            text[i] = '\t' + Items[i - 1] + (i < n ? Delimiter : Tail);
                        return text;
                }
            }
        }
    }
}
